<?php

/**
 * User form base class.
 *
 * @method User getObject() Returns the current form's model object
 *
 * @package    BootcampApp
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'firstname'   => new sfWidgetFormInputText(),
      'lastname'    => new sfWidgetFormInputText(),
      'email'       => new sfWidgetFormInputText(),
      'country_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => true)),
      'state'       => new sfWidgetFormInputText(),
      'locality'    => new sfWidgetFormInputText(),
      'timezone_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Timezone'), 'add_empty' => true)),
      'address'     => new sfWidgetFormInputText(),
      'postal_code' => new sfWidgetFormInputText(),
      'biography'   => new sfWidgetFormTextarea(),
      'birthday'    => new sfWidgetFormDate(),
      'company_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Company'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'firstname'   => new sfValidatorString(array('max_length' => 80)),
      'lastname'    => new sfValidatorString(array('max_length' => 80)),
      'email'       => new sfValidatorString(array('max_length' => 120)),
      'country_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'required' => false)),
      'state'       => new sfValidatorString(array('max_length' => 80, 'required' => false)),
      'locality'    => new sfValidatorString(array('max_length' => 80)),
      'timezone_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Timezone'), 'required' => false)),
      'address'     => new sfValidatorString(array('max_length' => 80)),
      'postal_code' => new sfValidatorString(array('max_length' => 20)),
      'biography'   => new sfValidatorString(array('max_length' => 450, 'required' => false)),
      'birthday'    => new sfValidatorDate(array('required' => false)),
      'company_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Company'))),
    ));

    $this->widgetSchema->setNameFormat('user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'User';
  }

}
